package com.jsbj.user.controller;


import com.alibaba.fastjson.JSONObject;
import com.jsbj.base.ResultBean;
import com.jsbj.framework.controller.BaseController;
import com.jsbj.user.entities.SysOrgExtend;
import com.jsbj.user.service.ISysOrgExtendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * <p>
 * 标段信息扩展表 前端控制器
 * </p>
 *
 * @author jsbj
 * @since 2022-08-05
 */
@RestController
@RequestMapping("/sys-org-extend")
@Api(value = "标段扩展表", tags = "标段扩展表")
@ApiIgnore
public class SysOrgExtendController extends BaseController {

    @Autowired
    private ISysOrgExtendService sysOrgExtendService;

    @ApiOperation("新增或编辑保存")
    @ApiImplicitParams({@ApiImplicitParam(paramType = "header", dataType = "String", name = "tenantCode", value = "租户id", required = true),
            @ApiImplicitParam(paramType = "header", dataType = "String", name = "userId", value = "用户登录id", required = true)}
    )
    @PostMapping("saveOrUpdateData")
    public ResultBean<JSONObject> saveOrUpdateData(@RequestBody SysOrgExtend sysOrgExtend){
        return sysOrgExtendService.saveOrUpdateData(sysOrgExtend);
    }

    @ApiOperation("查看详情")
    @ApiImplicitParams({@ApiImplicitParam(paramType = "header", dataType = "String", name = "tenantCode", value = "租户id", required = true),
            @ApiImplicitParam(paramType = "header", dataType = "String", name = "userId", value = "用户登录id", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "String", name = "orgCode", value = "标段编码", required = true)}
    )
    @GetMapping("getDetail")
    public ResultBean<List<SysOrgExtend>> getDetail(@RequestParam String orgCode){
        return new ResultBean<List<SysOrgExtend>>(sysOrgExtendService.getDetail(orgCode));
    }

    @GetMapping("/api/getDetailApi")
    public List<SysOrgExtend> getDetailApi(@RequestParam String orgCode, @RequestParam String tenantCode){
        return sysOrgExtendService.getDetailApi(orgCode, tenantCode);
    }

}

